package org.dreamwork.jasmine2.javac;

import org.dreamwork.jasmine2.parser.TaglibDirective;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: seth
 * Date: 2009-1-27
 * Time: 22:14:39
 */
public class JasminePageInfo {
    private String contentType;
    private String superClassName;
    private boolean autoFlush;
    private int buffSize;
    private List<String> importPackages = new ArrayList<String> ();
    private Map<String, Object> uris = new HashMap<String, Object> ();

    public String getContentType () {
        return contentType;
    }

    public void setContentType (String contentType) {
        this.contentType = contentType;
    }

    public String getSuperClassName () {
        return superClassName;
    }

    public void setSuperClassName (String superClassName) {
        this.superClassName = superClassName;
    }

    public boolean isAutoFlush () {
        return autoFlush;
    }

    public void setAutoFlush (boolean autoFlush) {
        this.autoFlush = autoFlush;
    }

    public int getBuffSize () {
        return buffSize;
    }

    public void setBuffSize (int buffSize) {
        this.buffSize = buffSize;
    }

    public List getImportPackages () {
        return importPackages;
    }

    public void addImportPackages (String ip) {
        importPackages.add (ip);
    }

    @SuppressWarnings ("unchecked")
    public void addUri (String prefix, TaglibDirective taglib) {
        String name = taglib.getName ();
        if (name != null) { // user control
            Map map = (Map) uris.get (prefix);
            if (map == null) {
                map = new HashMap ();
                uris.put (prefix, map);
            }
            map.put (name, taglib);
        } else
            uris.put (prefix, taglib);
    }

    public TaglibDirective getTaglib (String prefix, String name) {
        Object value = uris.get (prefix);
        if (value instanceof Map)
            return (TaglibDirective) ((Map) value).get (name);
        return (TaglibDirective) uris.get (prefix);
    }
}